﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SmallERP.MODEL.PrintManage;
using SmallERP.Bll.PrintManage;
using SmallERP.MODEL.FoundationModel;
using System.Runtime.InteropServices;
using Smallerp.Contracts;

namespace SmallERP.PrintManage
{
    public partial class FrmBoardDetail : Form
    {
        private int boardid = 0;

        [DllImport("kernel32.dll")]
        public static extern int WinExec(string exeName, int operType);

        public int BoardId { set { boardid = value; } }
        
        public FrmBoardDetail(IOperateDB inOp)
        {
            InitializeComponent();
            _OperateDb = inOp;
        }
        IOperateDB _OperateDb;
        private void FrmBoardDetail_Load(object sender, EventArgs e)
        {
            LinkGC();
        }
        private void LinkGC()
        {
            BoardDetail boardDetail = new BoardDetail(_OperateDb);
            gcBoardDetail.DataSource = boardDetail.GetBoardDetailInfo(boardid);
            gcBoardDetail.RefreshDataSource();
        }

        private void gvBoardDetail_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.Column.FieldName == "PicPath")
            {
                string fileName = ((BoardDetailInfo)gvBoardDetail.GetFocusedRow()).PicPath;
                if (fileName.Contains("jpg"))
                {
                    int ret = WinExec(@"explorer /n,/select," + fileName, 1);
                }
            }
        }

    }
}
